package com.ruoyi.yuanliao.controller;

import com.ruoyi.yuanliao.domain.TraceTransport;
import com.ruoyi.yuanliao.service.FarmerService;
import com.ruoyi.yuanliao.service.TraceTransportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @projectName: blockchain-fabric-group1
 * @package: com.ruoyi.yuanliao.controller
 * @className: TraceTransportController
 * @author: 刘乘滨
 * @description: TODO
 * @date: 2023/05/20 10:57
 * @version: 1.0
 */

@RestController
@RequestMapping("/changshang/yuanliao")
public class TraceTransportController {

    @Autowired
    TraceTransportService traceTransportService;

    @Autowired
    FarmerService farmerService;

    @Autowired
    RedisTemplate redisTemplate;

    @RequestMapping("/listCrops")
    public List<TraceTransport> listCrops(String deptId){
        List<TraceTransport> traceTransports = traceTransportService.listCrops(deptId);
        return traceTransports;
    }

    /**
     * @author wx
     * @Date 23:47 2020/11/7 0007
     * @Param [cropsId] 出库
     * @return com.ruoyi.common.core.domain.AjaxResult
     **/
    @GetMapping("/changeInToOut/{cropsId}")
    public int changeInToOut(@PathVariable("cropsId") String cropsId){
        return traceTransportService.changeInToOut(cropsId);
    }

    @PostMapping("/addTransport")
    public int addTransport(@RequestBody TraceTransport traceTransport){
        return traceTransportService.addTransport(traceTransport);
    }
}
